#!/bin/bash
while :
do
read -p "Please input a name:" name
if [ -f /work/test/1.log ];then
bb=`cat /work/test/1.log | awk -F: '{print $1}' | grep "$name"`
if [ "$bb" != "$name" ];then
aa=`echo $RANDOM | awk -F "" '{print $2 $3}'`
while :
do
dd=`cat /work/test/1.log | awk -F: '{print $2}' | grep "$aa"`
if [ "$aa" == "$dd" ];then
echo "数字已存在."
aa=`echo $RANDOM | awk -F "" '{print $2 $3}'`
else
break
fi
done
echo "$name:$aa" | tee -a /work/test/1.log
else
aa=`cat /work/test/1.log | grep "$name" | awk -F: '{print $2}'`
echo $aa
echo "重复名字."
fi
else
aa=`echo $RANDOM | awk -F "" '{print $2 $3}'`
echo "$name:$aa" | tee -a /work/test/1.log
fi
done